
# 一维IO的计算
def iou(set_a, set_b):
    x1 ,x2 = set_a
    y1, y2 = set_b
    left = max(x1, y1)
    right = min(x2 ,y2)

    if left > right:
        inter = 0
    else:
        inter = right - left

    union = (x2 - x1) + (y2 - y1) - inter

    iou = inter / union

    return iou

setA = [1, 9]
setB = [5, 10]
iou = iou(setB, setA)
print(iou)





